package com.szxy.datetest;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @Author: zwz
 * @Date:2020/9/30 12:10
 * @Description:com.szxy.datetest
 * @Version:1.0
 **/
public class ThreadLocalDateFormat {

    private static ThreadLocal<DateFormat> dateFormat = new ThreadLocal<DateFormat>(){
        @Override
        protected DateFormat initialValue() {
            return new SimpleDateFormat("yyyyMMdd");
        }
    };

    public static Date convert(String source) throws ParseException {
        return dateFormat.get().parse(source);
    }

}
